<?php
require('../vendor/autoload.php');

use BitWasp\Bitcoin\Key\PrivateKeyFactory;
use BitWasp\Bitcoin\Script\ScriptFactory;
use BitWasp\Bitcoin\Network\NetworkFactory;
use BitWasp\Bitcoin\Address\ScriptHashAddress;

$network = NetworkFactory::bitcoinRegtest();

$keys = [];
for($i=0;$i<3;$i++){
  $prv = PrivateKeyFactory::create(true);
  $keys[] = $prv->getPublicKey();
}

$redeemScript = ScriptFactory::scriptPubKey()->multiSig(2,$keys);
$p2sh = new ScriptHashAddress($redeemScript->getScriptHash());

echo 'multisig p2sh address => ' . $p2sh->getAddress($network) . PHP_EOL;